const elementUiCDataOrMethod = {
  data() {
    var validatePass = (rule, value, callback) => {
      // mixins {field: "desc", fullField: "desc", type: "string", validator: ƒ}
      console.log('mixins', rule, value)
      if (value === '') {
        callback(new Error('请输入密码'))
      } else {
        // if (this.ruleForm.checkPass !== '') {
        //   this.$refs.ruleForm.validateField('checkPass')
        // }
        callback()
      }
    }
    return {
      tableColumnsMixin: [
        {
          type: 'selection',
          width: 60,
          align: 'center',
          fixed: 'left'
        },
        {
          title: 'Name',
          key: 'name',
          width: 100,
          sortable: true
        },
        {
          title: 'Age',
          key: 'age'
        },
        {
          title: 'Action',
          slot: 'action',
          width: 150,
          align: 'center',
          fixed: 'right'
        }
      ],
      tableMixinData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄',
        status: 1
      }],
      tableLoading:false,
      /* 分页*/
      pageNum: 1,
      pageSize: 10,
      pageTotal: 100,
      /* 表单*/
      formModel: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      fromRules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        region: [
          { required: true, message: '请选择活动区域', trigger: 'change' }
        ],
        date1: [
          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
        ],
        date2: [
          { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
        ],
        type: [
          { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
        ],
        resource: [
          { required: true, message: '请选择活动资源', trigger: 'change' }
        ],
        desc: [
          { validator: validatePass, trigger: 'blur' }
        ]
      },
      /* 循环的表单*/
      forFormRules: {
        name: [{
          required: true,
          message: '请输入名称',
          trigger: 'blur' }],
        phone: [{
          required: true,
          message: '请输入账号手机号',
          trigger: 'blur' }],
        username: [{
          required: true,
          message: '请输入账号名称',
          trigger: 'blur' }],
        password: [{
          required: true,
          message: '请输入密码',
          trigger: 'blur' }
        ]
      }, // 添加校验
      forFormModal: {
        name: '',
        userList: [{
          phone: '',
          username: '',
          password: ''
        }]
      },
      /* modal部分*/
      modalTitle: 'fai',
      dialogVisible: false,
      /*时间和日期*/
      datePickerOptions:{
        disabledDate (date) {
          return date && date.valueOf() < Date.now() - 86400000;
        },
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      }
    }
  },
  computed: {
    // ...mapState('user', ['token', 'userInfo'])
  },
  watch: {

  },
  created() {

  },
  mounted() {

  },
  methods: {
    tableHandleCheckClick(row) {
      console.log('mixins的handleCheckClick', row)
    },
    tableHandleEditClick(row) {
      console.log('mixins的handleCheckClick', row)
    },
    tableHandleDeleteClick(row) {
      console.log('mixins的handleCheckClick', row)
    },
    tableSingleCheckSelect(rows, row) {
      // const selected = rows.length && rows.indexOf(row) !== -1
      // if (selected) {
      //   this.vinArr.push(row.id)
      // } else {
      //   // 取消勾选
      //   this.vinArr.splice(this.vinArr.findIndex(item => item === row.id), 1)
      // }
    },
    /* 分页*/
    pageHandleSizeChange(val) {
      console.log(`mixins pageHandleSizeChange: ${val}`)
      // this.pageSize = val
      // this.vehicleListReq()
    },
    pageHandleCurrentChange(val) {
      console.log(`mixins pageHandleCurrentChange: ${val}`)
      // this.pageNum = val
      // this.vehicleListReq()
    },
    /* 底部btn*/
    saveBtnClick() {
      console.log(`mixins saveBtnClick`)
    },
    /* form表单*/
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    },
    /* modal部分*/
    beforeCloseModal() {
      this.dialogVisible = false
      console.log('mixins beforeCloseModal')
    },
    modalConfirmBtn(){

    },
    /* 通知*/
    iMessage(type,message,duration) {
      type=type||'success'
      console.log('type', type)
      this.$Message[type]({
        background: true,
        content: message||'这是一条带背景色的通知',
        duration: duration||2.5
      });
    },
    /*提示*/
    iNotify(type,message,title,duration) {
      type=type||'success'
      console.log('type', type)
      this.$Notice[type]({
        title: title||'请传入标题',
        desc: message||'请传入提示消息',
        duration: duration||2.5,
        top: 40
      });
    },
    /*确定*/
    iConfirm(title,message) {
      return new Promise((resolve, reject) => {
        this.$Modal.confirm({
          title: title||'确认框',
          content: message||'你确定要删除吗',
          okText: '确定',
          cancelText: '取消',
          onOk: () => {
            resolve("OK");
          },
          onCancel: () => {
            reject();
          }
        });
      })
    },

    /*日期*/
    datePickerConfirm(val1,val2){
      console.log("mixins datePickerConfirm",val1,val2)
    }
  }
}

export default elementUiCDataOrMethod
